<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1" name="viewport">

    <title>添加医生</title>

    <!-- Bootstrap -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
    <style>
        #form {
            padding-right: 100px;
            margin-top: 150px;
            width: 40%;
        }

        #image {
            padding-left: 100px;
            padding-top: 100px;
        }
    </style>
</head>
<body background="img/background.jpg">
<div class="row">
    <img class="col-md-6" id="image" src="img/pregnant.svg"/>
    <form background-color="width" class="col-md-6" id="form">
        <div class="form-group">
            <label for="exampleInputEmail1">医生ID</label>
            <input class="form-control" id="id" placeholder="text" required="required" type="text"/>
        </div>
        <div class="checkbox">
            <strong>性别</strong>：<input checked="checked" name="sex" type="radio" value="woman">女
            <input checked="" name="sex" type="radio" value="man">男
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">电话</label>
            <input class="form-control" id="phone" placeholder="text" required="required" type="phone"/>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">电子邮箱</label>
            <input class="form-control" id="email" placeholder="Email" required="required" type="email"/>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail1">姓名</label>
            <input class="form-control" id="name" placeholder="text" required="required" type="text"/>
        </div>
        <button class="btn btn-default" onclick="window.location.href='/'" type="submit">返回</button>
        <button class="btn btn-default" id="submit" onclick="return false;" type="submit">提交</button>
    </form>
</div>
</body>
<script>
    function createUser() {
        var user = new Object;
        user.id = null;
        user.birthday = null;
        user.gender = null;
        user.phone = null;
        user.phone2 = null;
        user.email = null;
        user.password = null;
        user.loginState = null;
        user.inService = null;
        user.admin = null;
        user.sessionId = null;
        user.name = null;
        return user;
    }

    var User = createUser();


    $(document).ready(function () {
        $("#submit").click(function () {
            User.id = $("#id").val();
            User.gender = $('input:radio:checked').val();
            User.phone = $("#phone").val();
            User.email = $("#email").val();
            User.name = $("#name").val();
            // $("#form").hide();
            // console.log('12312312')
            $.post("/addUser",
                User,
                function (data, status) {
                    if (status == "success") {
                        alert("提交成功");
                    }
                });
        });

    });
</script>
</body>
</html>